#ifndef ITEM_GENERATOR_H_
#define ITEM_GENERATOR_H_

#include <stdio.h>
#include <wchar.h>
#include <irrlicht.h>
#include <iostream>
#include <vector>

#include "StaticEntity.h"
#include "World.h"

/*!
	The item generator class provides an invisible entity which spawns a certain type of StaticEntity. It has a limited number of children and the time to spawn an entity can be changed. */
class ItemGenerator: public virtual Entity
{
	protected:
	std::map<std::string, std::string> item_entinfo__;	/**< Static entity's ent_info, used to spawn a new StaticEntity. */
	std::vector<StaticEntity*> childs__;			/**< The vector containing all the children. */
	unsigned int max_childs__;				/**< The max number of children. Default is 8. */
	float timeToSpawn__;					/**< The time to wait before spawning a new child. Default it 15 seconds. */
	float elapsedTime__;					/**< The elapsed time from the last spawn (or ItemGenerator's creation. */

	public:
	/*! Constructor. Adds an EmptySceneNode, store it into node__ (from Entity's class) and initialize the bases into item_entinfo__ (model, skin, classname and scale). */
	ItemGenerator(const std::string& entityModel, const std::string& entitySkin, const std::string& entity_type, const std::string& scale);
	/*! Destructor. It removes itself from all children in the childs__ vector. */
	virtual ~ItemGenerator();

	/*! Set the maximum number of childred. No safety checks are done you can have a strong amount of child. */
	void setMaxChildren(unsigned int max_child);
	/*! Set the time to spawn. No safety checks are done; if tts is <= 0.0f, then it will take n frames to spawn n child. */
	void setTimeToSpawn(float tts);
	/*! Removes a child from the entity list. This method is usually called by children themselves. */
	virtual void removeChild(StaticEntity* child);
	/*! The update method, checks for elapsed time and max children, then spawn a child if needed. */
        virtual void update();
};

#endif

